<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>个人中心</title>
		<link rel="stylesheet" type="text/css" href="../css/personal_center.css" />
	</head>
	<body>
	<nav class="nav">
			<div class="nav_logo">FOG</div>
			<div class="nav_content">
				<div class="nav_content_text"><a href="../index.html">首页</a></div>
				<div class="nav_content_text"><a href="tree_hole.html">树洞</a></div>
				<div class="nav_content_text"><a href="personal_center.html">我的</a></div>
				<div class="nav_content_text"><a href="#" id="logoutLink">退出</a></div>
			</div>
		</nav>

<!--User-->
		<div class="nav-divider"></div>
		<div class="ellipse-container"></div>	
		<div class="profile-container">
			<img src="../img/1.jpg" class="center-avatar" alt="用户头像">
			<div class="user-name" id="userName">USER</div>
			<div class="user-signature">只要淡淡的 就会顺顺的</div>
		</div>

		<script>
			// 获取并显示当前登录用户名
			const currentUser = localStorage.getItem('username') || '123';
			document.getElementById('userName').textContent = currentUser;

			// 退出功能
			document.getElementById('logoutLink').addEventListener('click', function(e) {
				e.preventDefault();
				if (confirm(`您是否确认退出账户${currentUser}？`)) {
					localStorage.removeItem('username');
					window.location.href = '../index.html';
				}
			});
		</script>
	</body>
</html>
